﻿using System;
using System.Collections.Generic;
using System.Text;
using Hkwl.WorldExpo.Merchant.Model;
using System.Collections;

namespace Hkwl.WorldExpo.Merchant.DataAccess.Impl.IBatisNet
{
    public class LogSqlMapDao : BaseSqlMapDao, ILogDao
    {

        #region NxBookLog 对象

        public NxBookLog GetNxBookLogById(int bookLogId)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region NxQueryLog 对象

        public NxQueryLog GetNxQueryLogById(int queryId)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region NxSendLog 对象

        public NxSendLog GetNxSendLogById(int sendId)
        {
            throw new NotImplementedException();
        }

        public int GetSendNumByProjectId(int projectId)
        {
            return ExecuteQueryForObject<int>("SelectSendNumCount", projectId);
        }

        public int GetSendNumByClientId(int projectId, int clientId)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectId"] = projectId;
            ht["ClientId"] = clientId;
            return ExecuteQueryForObject<int>("SelectSendNumCountByClient", ht);
        }

        public int GetUseNumByProjectId(int projectId)
        {
            return ExecuteQueryForObject<int>("SelectUseNumCount", projectId);
        }

        public int GetUseNumByClientId(int projectId, int clientId)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectId"] = projectId;
            ht["ClientId"] = clientId;
            return ExecuteQueryForObject<int>("SelectUseNumCountByClient", ht);
        }

        public IList<IList> GetNxSendNumCollection(int projectId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectId"] = projectId;

            count = ExecuteQueryForObject<int>("SelectSendNumCountByClient", ht);
            return ExecuteQueryForList<IList>("SelectSendLogCollection", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        public IList<IList> GetNxUseNumCollection(int projectId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectId"] = projectId;

            count = ExecuteQueryForObject<int>("SelectUseNumCountByClient", ht);
            return ExecuteQueryForList<IList>("SelectSendLogCollectionByUse", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        public IList<IList> GetClientReporting(int merchantId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["MerchantId"] = merchantId;

            IList<IList> countCollection = ExecuteQueryForList<IList>("GetClientCountReporting", ht);
            count = countCollection.Count;
            return ExecuteQueryForList<IList>("GetClientCountReporting", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        public IList<IList> GetProjectReporting(int merchantId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["MerchantId"] = merchantId;

            IList<IList> countCollection = ExecuteQueryForList<IList>("GetProjectCountReporting", ht);
            count = countCollection.Count;
            return ExecuteQueryForList<IList>("GetProjectCountReporting", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        public IList<NxSendLog> GetSendLogCollection(int merchantId, int clientId, int sendFlag, int useFlag,int pageIndex,int pageSize,ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["MerchantId"] = merchantId;
            ht["ClientId"] = clientId;
            ht["IsSendFlag"] = sendFlag;
            ht["IsUseFlag"] = useFlag;

            count = ExecuteQueryForObject<int>("SelectSendLogFlagCount", ht);
            return ExecuteQueryForList<NxSendLog>("SelectSendLogFlagCollection", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        #endregion
    }
}
